import { http } from "@/utils";

export function getTableList(params = {}) {
  return http.post("/tool/generate/list", params);
}

export function getGenTable(tableId) {
  return http.get(`/tool/generate/detail/${tableId}`);
}

export function updateGenTable(params) {
  return http.post("/tool/generate/update", params);
}

export function getDbTableList(params = {}) {
  return http.post("/tool/generate/db/list", params);
}

export function importTable(params = []) {
  return http.post("/tool/generate/import", params);
}

export function deleteTable(tableId) {
  return http.post("/tool/generate/delete", tableId);
}

export function deleteBatchTable(tableIds) {
  return http.post("/tool/generate/deleteBatch", tableIds);
}

export function previewTable(tableId) {
  return http.get(`/tool/generate/preview/${tableId}`);
}

export function downloadTable(tableId) {
  return http.get(`/tool/generate/download/${tableId}`, {
    headers: { "Content-Type": "application/x-www-form-urlencoded" },
    responseType: "blob",
  });
}
